package com.omronservice.app.curve.service;


import com.omronservice.app.curve.bean.maincurve.*;
import com.omronservice.app.curve.mapper.CurveMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


@Service
public class CurveService {


    @Autowired
    CurveMapper curveMapper;


    public List<SelectEquBean> selectEqu(String lineId) {
        return curveMapper.selectEqu(lineId);
    }

    public List<SelectCapacityBean> selectCapacity(String lineId) {
        return curveMapper.selectCapacity(lineId);
    }
    public String selectCapacityString(String lineId, String equipmentId,  String beginTime,String endDate) {
        return curveMapper.selectCapacityString( lineId,  equipmentId, beginTime,endDate);
    }

    public List<SelectAllDataResBean> selectAllData(SelectAllDataBean bean) {
        return curveMapper.selectAllData(bean);
    }

    public List<MainChildBean> selectAllData2(SelectAllDataBean bean) {
        return curveMapper.selectAllData2(bean);
    }

    public List<MainChildBean> selectOutput(SelectAllDataBean bean) {
        return curveMapper.selectOutput(bean);
    }

    public List<HashMap<String,String>> selectAllLine( ) {
        return curveMapper.selectAllLine();
    }

    public List<HashMap<String,String>> selectEqByLineId(String lineId ) {
        return curveMapper.selectEqByLineId(lineId);
    }

    public List<HashMap<String,String>> selectPartNoById(String lineId,String[] eqId ) {
        List<HashMap<String,String>> data=curveMapper.selectPartNoById(lineId,eqId);
        List<HashMap<String,String>> resultList=new ArrayList<>();
        if(data!=null&&data.size()>0){
            String portNo=data.get(0).get("partNo");
            resultList.add(data.get(0));
            for(HashMap<String,String> map:data){
                if(portNo.equals(map.get("partNo"))){
                    continue;
                }else {
                    portNo = map.get("partNo");
                    resultList.add(map);
                }
            }
        }

        return resultList;
    }

    public List<HashMap<String,String>> selectPartNoALLById(String lineId,String[] eqId ) {
        return curveMapper.selectPartNoById(lineId,eqId);
    }

    public List<HashMap<String,String>> selectCLASS( ) {
        return curveMapper.selectCLASS();
    }
}
